home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / redo / redoSplitFileNode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.9 KB  |  202 lines

  1. /*
  2.  *   $RCSfile: redoSplitFileNode.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:57 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38.  
  39. #include "sysdefs.h"
  40. #include "ess.h"
  41. #include "checking.h"
  42. #include "trace.h"
  43. #include "error.h"
  44. #include "list.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "latch.h"
  52. #include "semaphore.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "log.h"
  57. #include "pool.h"
  58. #include "volume.h"
  59. #include "logrecs.h"
  60. #include "trans.h"
  61. #include "bitmap.h"
  62. #include "file.h"
  63. #include "openlog.h"
  64. #include "bf_extfuncs.h"
  65. #include "bm_extfuncs.h"
  66. #include "trans_extfuncs.h"
  67. #include "redo_extfuncs.h"
  68. #include "logaction.h"
  69. #include "util_funcs.h"
  70. #include "thread_globals.h"
  71. #include "bf_globals.h"
  72. #include "log_globals.h"
  73. #include "log_extfuncs.h"
  74.  
  75.  
  76.  void
  77. redoSplitFileNode (
  78.  
  79.     LOGRECORDHDR        *record 
  80. )
  81. {
  82.  
  83.     register int        i;
  84.     register PID        *pid;
  85.     register NODEPAGE    *nodePage;
  86.     register GROUPLINK    *nodeLink;
  87.     register char        *data;
  88.     DIRTYPAGEINFO        *dirtyInfo;
  89.     PID                    *pidList;
  90.     LRC                    *lrcList;
  91.     char                *filePageList;
  92.  
  93.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
  94.  
  95.     /*
  96.      *    get pointers to the lists of pages and lrc's involved
  97.      */
  98.     filePageList = (char *) GET_LOG_IMAGE(record, 0);
  99.     pidList = (PID *) GET_LOG_IMAGE(record, 1);
  100.     lrcList = (LRC *) GET_LOG_IMAGE(record, 2);
  101.  
  102.     /*
  103.      *    process the 3 pages that are part of the split
  104.      */
  105.     for (i = 0; i < 3; i++)    {
  106.  
  107.         /*
  108.          *    get a pointer to the pid in the record
  109.          */
  110.         pid = pidList+i;
  111.         TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid%d:%d", i, pid->page));
  112.  
  113.         /*
  114.          *    get a pointer to the name in the record
  115.          */
  116.         data = filePageList + i*FILE_PAGESIZE;
  117.  
  118.  
  119.         /*
  120.          *    check to see if the page is in the dirty page list
  121.          */
  122.         if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL)    {
  123.  
  124.             /*
  125.              *    don't need to redo
  126.              */
  127.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
  128.             continue;
  129.         }
  130.  
  131.         /*
  132.          *    check to see if the lrc on the page is greater than
  133.          *    the lrc in the log record
  134.          */
  135.         if (CHECK_PAGE_LRC_LESS_DIRTYINFO(lrcList[i], record->recordLSN, dirtyInfo)) {
  136.  
  137.             /*
  138.              *    don't need to redo
  139.              */
  140.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
  141.             continue;
  142.         }
  143.  
  144.         /*
  145.          * Read in first page of file and grab node type
  146.          */
  147.         if ((nodeLink = bf_ReadPage(UserBufGroup, pid, FILE_PAGE2SIZE, BF_SEM)) == NULL) {
  148.  
  149.             SM_ERROR(TYPE_FATAL, Active->errno);
  150.         }
  151.  
  152.         /*
  153.          *    get a pointer to the node page
  154.          */
  155.         nodePage = (NODEPAGE *) nodeLink->bufFrame;
  156.  
  157.         /*
  158.          *    check to see if the lsn on the page is greater than
  159.          *    the lsn in the log record
  160.          */
  161.         if (compareLRC( lrcList+i, &(nodePage->header.lrc)) <= 0)    {
  162.  
  163.             /*
  164.              *    don't need to redo
  165.              *    mark the page lrc
  166.              */
  167.             TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
  168.             dirtyInfo->lrc = nodePage->header.lrc;
  169.  
  170.             /*
  171.              *    release the page
  172.              */
  173.             signalSemaphore( &(nodeLink->pageHash->semaphore) );
  174.             bf_UnfixPage(nodeLink, BF_DEFAULT, FALSE);
  175.             continue;
  176.         }
  177.  
  178.         /*
  179.          *    copy in the update
  180.          */
  181.         bcopy(data, nodeLink->bufFrame, FILE_PAGESIZE);
  182.  
  183.         /*
  184.          *    mark the lrc on the page
  185.          *    Set up the firstLSN/LRC for the page
  186.          */
  187.         nodePage->header.lrc = *(lrcList+i);
  188.         DEPEND_LOG(nodeLink->pageHash, 0, &(record->recordLSN), (lrcList+i));
  189.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", nodePage->header.lrc.count));
  190.  
  191.         /* 
  192.          *    release  the page semaphore
  193.          */
  194.         signalSemaphore( &(nodeLink->pageHash->semaphore) );
  195.  
  196.         /*
  197.          *    release and dirty the page
  198.          */
  199.         bf_UnfixPage(nodeLink, BF_DEFAULT, TRUE);
  200.     }
  201. }
  202.